cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 11)
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_C_COMPILER   ${CC})
SET(CMAKE_CXX_COMPILER ${CXX})
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)


add_definitions(-fno-rtti)
PROJECT(uac_app)

include_directories("./include")



set(UAC_AUDIO_ALGORITHM
    # ${CMAKE_CURRENT_LIST_DIR}/lib/libaec_wake_float.so
    # ${CMAKE_CURRENT_LIST_DIR}/lib/libbeamform.so
    # ${CMAKE_CURRENT_LIST_DIR}/lib/libagc.so
    # ${CMAKE_CURRENT_LIST_DIR}/lib/libcae.so
    # ${CMAKE_CURRENT_LIST_DIR}/lib/libanr.so
    ${CMAKE_CURRENT_LIST_DIR}/lib/libdrm.so
    ${CMAKE_CURRENT_LIST_DIR}/lib/librockit.so
)

set(LIB_SOURCE
    src/graph_control.cpp
    src/uac_control.cpp
    src/SampleNode.cpp
    src/uevent.cpp
)
link_libraries(${UAC_AUDIO_ALGORITHM})


add_library(rkuac SHARED ${LIB_SOURCE})
target_link_libraries(rkuac pthread
    ${UAC_AUDIO_ALGORITHM}
)

set(CMAKE_BUILD_TYPE Debug CACHE STRING "set build type to debug")

set(SOURCE
    src/main.cpp

    ${LIB_SOURCE}
)



set(UAC_APP_DEPENDENT_LIBS
    pthread
)


install(FILES ${UAC_AUDIO_ALGORITHM} DESTINATION lib) 

ADD_EXECUTABLE(uac_app ${SOURCE})
target_link_libraries(uac_app ${UAC_APP_DEPENDENT_LIBS})

add_subdirectory(./voice)

install(TARGETS rkuac DESTINATION lib)
install(DIRECTORY ./uac DESTINATION include
        FILES_MATCHING PATTERN "*.h")
install(DIRECTORY configs/ DESTINATION share/uac_app FILES_MATCHING PATTERN "*.json")
install(TARGETS uac_app DESTINATION bin)
install(DIRECTORY . DESTINATION bin
        FILES_MATCHING PATTERN "*.sh"
        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
        GROUP_READ GROUP_WRITE GROUP_EXECUTE
        WORLD_READ WORLD_WRITE WORLD_EXECUTE)
        
